from pymongo import MongoClient

server_client = MongoClient('47.104.130.19', 27017)
# server_db = server_client['zhilian_db']
# server_posts, server_corps = server_db['zhilian_posts'], server_db['zhilian_corps']

server_db = server_client['yingcai_db']
server_posts, server_corps = server_db['yingcai_posts'], server_db['yingcai_corps']

local_client = MongoClient('127.0.0.1', 27017)
# local_db = local_client['zhilian_db']
# local_posts, local_corps = local_db['zhilian_posts'], local_db['zhilian_corps']

local_db = local_client['yingcai_db']
local_posts, local_corps = local_db['yingcai_posts'], local_db['yingcai_corps']

postCount = 0
corpCount = 0

for item in local_posts.find():
    id = server_posts.insert_one(item)
    if id:
        postCount += 1
        print('success insert one job!total insert=' + str(postCount))

for item in local_corps.find():
    del item['_id']

    id = server_corps.insert_one(item)
    if id:
        corpCount += 1
        print('success insert one company!total insert=' + str(corpCount))
